<?php
	class SchoolModel extends CI_Model {
		// 表名
		static $schoolTable = "school";
		static $campusTable = "school_campus";
		static $schoolUserTable = "school_user";
		static $schoolStudentTable = "school_student";
		static $schoolLessonTable = "school_lesson";
		static $areaTable = "area";
		static $customMenuTable = "school_custom_menu";
		static $chargeTable = "school_charge";
		static $wxUserBindTable = "wx_user_bind";
		static $gateTable = "gate";
		static $gateTaskTable = "gate_task";
		static $smartLockTable = "smart_lock";
		static $smartLockUnlockRecordTable = "smart_lock_unlock_record";
		static $smartLockStudentWhiteListTable = "smart_lock_student_white_list";
		static $schoolStudentGroupTable = "school_student_group";
	    public function __construct() {
	        parent::__construct();
	    }

	    // 获取学校信息
	    public function get_school_info($schoolId){
	    	$this->db->where("id", $schoolId);
	    	$schoolInfo = $this->db->get(self::$schoolTable)->row_array();
	    	// 基础属性
	    	if($schoolInfo) {
	    		$schoolInfo['schoolFromName'] = get_school_from_name($schoolInfo['school_from']);
	    	}
	    	return $schoolInfo;
	    }
		
		// 通过学校名称获取学校信息
		public function get_school_info_by_name($name){
			$this->db->where("school_name", $name);
			$schoolInfo = $this->db->get(self::$schoolTable)->row_array();
			return $schoolInfo;
		}

		// 获取超星学校
		public function get_school_info_by_school_from($schoolFrom){
			$this->db->where("school_from", $schoolFrom);
			$this->db->where("is_delete", 0);
			$schoolInfo = $this->db->get(self::$schoolTable)->row_array();
			return $schoolInfo;
		}

	    // 检查学校id是否存在
	    public function check_hzy_schoolid_exists($hzySchoolId, $schoolId){
	    	$where  = "`school_x_id`='{$hzySchoolId}' AND `id` != '{$schoolId}' AND `school_from`='". X_DATA_HAOZHUANYE ."'";
	    	$this->db->where($where);
	    	$schoolInfo = $this->db->get(self::$schoolTable)->row_array();
	    	return $schoolInfo;
		}
		
	    // 检查银通学校id是否存在
	    public function check_yt_schoolid_exists($ytSchoolId, $schoolId){
	    	$where  = "`school_x_id`='{$ytSchoolId}' AND `id` != '{$schoolId}' AND `school_from`='". X_DATA_YINTONG ."'";
	    	$this->db->where($where);
	    	$schoolInfo = $this->db->get(self::$schoolTable)->row_array();
	    	return $schoolInfo;
		}

		// 检查超星学校id是否存在
		public function check_chaoxing_schoolid_exists($xSchoolId, $schoolId){
			$where  = "`school_x_id`='{$xSchoolId}' AND `id` != '{$schoolId}' AND `school_from`='". X_DATA_CHAOXING ."'";
			$this->db->where($where);
			$schoolInfo = $this->db->get(self::$schoolTable)->row_array();
			return $schoolInfo;
		}

		// 检查电信学校id是否存在
		public function check_dianxin_schoolid_exists($xSchoolId, $schoolId){
			$where  = "`school_x_id`='{$xSchoolId}' AND `id` != '{$schoolId}' AND `school_from`='". X_DATA_DIANXIN ."'";
			$this->db->where($where);
			$schoolInfo = $this->db->get(self::$schoolTable)->row_array();
			return $schoolInfo;
		}
		// 检查斐宸学校id是否存在
		public function check_feichen_schoolid_exists($xSchoolId, $schoolId){
			$where  = "`school_x_id`='{$xSchoolId}' AND `id` != '{$schoolId}' AND `school_from`='". X_DATA_FEICHEN ."'";
			$this->db->where($where);
			$schoolInfo = $this->db->get(self::$schoolTable)->row_array();
			return $schoolInfo;
		}
	    // 根据学校ID，获取学校信息
	    public function get_school_info_by_x_id($xSchoolId){
	    	$this->db->where("school_x_id", $xSchoolId);
	    	$schoolInfo = $this->db->get(self::$schoolTable)->row_array();
	    	return $schoolInfo;
	    }

	    // 获取学校列表
	    public function get_school_list($params = ""){
			$where = "1 AND 1";
			// 软删除
			if(isset($params['isDelete'])) $where .= " AND `is_delete`='{$params['isDelete']}'";
	    	// 学校类型
	    	if(isset($params['schoolFrom'])) $where .= " AND `school_from`='{$params['schoolFrom']}'";
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 读取指定列
			if(isset($params['field'])) $this->db->select($params['field']);
			// 某个省
			if(isset($params['provinceCode'])) $where .= " AND `school_province`='{$params['provinceCode']}'";
			// 某个市
			if(isset($params['cityCode'])) $where .= " AND `school_city`='{$params['cityCode']}'";
			// 某个区
			if(isset($params['areaCode'])) $where .= " AND `school_area`='{$params['areaCode']}'";
			// 开启教师考勤
			if(isset($params['enableTeacherSign'])) $where .= " AND `enable_teacher_sign`='{$params['enableTeacherSign']}'";
	    	// 关键字筛选
	    	if(isset($params['keyword'])) $where .= " AND `school_name` LIKE '%{$params['keyword']}%'";
			// 排序
			if(isset($params['orderBy'])) {
				$this->db->order_by($params['orderBy']);
			} else {
				$this->db->order_by('id ASC');
			}
	    	$this->db->where($where);

	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) {
	    		$result = $this->db->count_all_results(self::$schoolTable);
	    	} else {
	    		$result = $this->db->get(self::$schoolTable)->result_array();
	    		foreach($result as &$school) {
	    			$school['schoolFromName'] = get_school_from_name($school['school_from']);
	    		}
	    	}
	    	return $result;
	    }
	    // 获取教师列表
	    public function get_teacher_list($params = ""){
			// 传allUserType就获取user,否则只获取教师
			if(isset($params['allUserType'])) {
				$where = "1";
			} else {
				$where = "`user_type`=". USER_TYPE_TEACHER;
			}
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 读取指定列
	    	if(isset($params['field'])) $this->db->select($params['field']);
	    	// 学校id
	    	if(isset($params['schoolId'])) $where .= " AND `school_id`='{$params['schoolId']}'";
	    	// 关键字筛选
	    	if(isset($params['keyword'])) $where .= " AND `realname` LIKE '%{$params['keyword']}%'";
	    	// 用户集
	    	if(isset($params['userId'])) $where .= " AND `id` IN ({$params['userId']})";
	    	// 删除状态
			if(isset($params['isDelete'])) $where .= " AND `is_delete`='{$params['isDelete']}'";
			// 筛选账号
			if(isset($params['username'])) $where .= " AND `username`= '{$params['username']}'";
			// 筛选姓名
			if(isset($params['realname'])) $where .= " AND `realname`= '{$params['realname']}'";
			// 任课班级
			// if(isset($params['classId'])) $where .= " AND FIND_IN_SET('{$params['classId']}', `class_ids`)";
			// 是否已录入人脸
			if(isset($params['hasFaceImage'])) {
				if($params['hasFaceImage'] == 1) {
					$where .= " AND `face_image` != ''";
				} else {
					$where .= " AND `face_image` = ''";
				}
			}
			// 是否已录入人脸或物理卡号
			if(isset($params['hasFaceImageOrRealcard'])) {
				if($params['hasFaceImageOrRealcard'] == 1) {
					$where .= " AND (`face_image` != '' OR `realcard` != '' )";
				}
			}
			$this->db->where($where);
			// 排序
			if(isset($params['orderBy'])) {
				$this->db->order_by($params['orderBy']);
			}
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) {
	    		$result = $this->db->count_all_results(self::$schoolUserTable);
	    	} else {
	    		$result = $this->db->get(self::$schoolUserTable)->result_array();	
	    	}
	    	return $result;
		}

		// 获取教师列表
		public function get_teacher_list_join_bind($params = ""){
			$teacherTb = self::$schoolUserTable;
			$wxUserBindTb = self::$wxUserBindTable;
			// 连表查询
			$bindTeacher = BIND_TYPE_TEACHER;
			$this->db->join($wxUserBindTb, "{$teacherTb}.id = {$wxUserBindTb}.bind_user_id AND {$wxUserBindTb}.is_delete=0 AND {$wxUserBindTb}.bind_user_type= {$bindTeacher} AND {$wxUserBindTb}.wx_user_id!=0", 'left');
			$this->db->group_by("{$teacherTb}.id");

			// 传allUserType就获取user,否则只获取教师
			if(isset($params['allUserType'])) {
				$where = "1";
			} else {
				$where = "{$teacherTb}.`user_type`=". USER_TYPE_TEACHER;
			}
			// 分页
			if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
			// 读取指定列
			if(isset($params['field'])) $this->db->select($params['field']);
			// 学校id
			if(isset($params['schoolId'])) $where .= " AND {$teacherTb}.`school_id`='{$params['schoolId']}'";
			// 关键字筛选
			if(isset($params['keyword'])) $where .= " AND {$teacherTb}.`realname` LIKE '%{$params['keyword']}%'";
			// 用户集
			if(isset($params['userId'])) $where .= " AND {$teacherTb}.`id` IN ({$params['userId']})";
			// 删除状态
			if(isset($params['isDelete'])) $where .= " AND {$teacherTb}.`is_delete`='{$params['isDelete']}'";
			// 筛选账号
			if(isset($params['username'])) $where .= " AND {$teacherTb}.`username`= '{$params['username']}'";
			// 筛选姓名
			if(isset($params['realname'])) $where .= " AND {$teacherTb}.`realname`= '{$params['realname']}'";
			// 是否已录入人脸
			if(isset($params['hasFaceImage'])) {
				if($params['hasFaceImage'] == 1) {
					$where .= " AND {$teacherTb}.`face_image` != ''";
				} else {
					$where .= " AND {$teacherTb}.`face_image` = ''";
				}
			}
			// 是否已录入人脸或物理卡号
			if(isset($params['hasFaceImageOrRealcard'])) {
				if($params['hasFaceImageOrRealcard'] == 1) {
					$where .= " AND ({$teacherTb}.`face_image` != '' OR {$teacherTb}.`realcard` != '' )";
				}
			}

			// 是否已绑定
			if(isset($params['bind'])) {
				if($params['bind'] == 1) {
					$bindTeacher = BIND_TYPE_TEACHER;
					$where .= " AND {$wxUserBindTb}.`is_delete`='0'";
					$where .= " AND {$wxUserBindTb}.`wx_user_id`!='0'";
					$where .= " AND {$wxUserBindTb}.`bind_user_type`='{$bindTeacher}'";
				} elseif($params['bind'] == 2) {
					// 教师未绑定情况
					$bindStudent = BIND_TYPE_STUDENT;
					$where .= " AND ({$wxUserBindTb}.`bind_user_type` IS NULL OR {$wxUserBindTb}.`bind_user_type`='{$bindStudent}')";
				}
			}
			$this->db->where($where);
			// 连表查询不能没有这个
			// 用.*查询比较慢
			// $this->db->select("{$studentTb}.*");
			$this->db->select("{$teacherTb}.*");
			// 排序
			if(isset($params['orderBy'])) {
				$this->db->order_by("{$teacherTb}." . $params['orderBy']);
			}
			// 是否只获取条数
			if(isset($params['getRowNumber'])) {
				$result = $this->db->count_all_results(self::$schoolUserTable);
			} else {
				$result = $this->db->get(self::$schoolUserTable)->result_array();	
			}
			return $result;
		}

	    // 获取学校人员信息，包括管理员和教师
	    public function get_school_user_info($schoolUserId) {
	    	$this->db->where("id", $schoolUserId);
	    	$schoolUser = $this->db->get(self::$schoolUserTable)->row_array();
	    	// 如果是学校管理员
	    	if($schoolUser && $schoolUser['user_type'] == USER_TYPE_SCHOOL) {
	    		$schoolUser['realname'] = '学校管理员';
	    		$schoolUser['headimgurl'] = UP_URL. "default/man.jpg";
	    	}

	    	return $schoolUser;
		}
		
		// 获取学校人员信息，包括管理员和教师,如果是管理员，也返回管理员名字
		public function get_school_user_info_realname($schoolUserId) {
			$this->db->where("id", $schoolUserId);
			$schoolUser = $this->db->get(self::$schoolUserTable)->row_array();

			return $schoolUser;
		}

	    // 获取教师信息
	    public function get_teacher_info($teacherId){
	    	$this->db->where("id", $teacherId);
    		$this->db->where("user_type", USER_TYPE_TEACHER);
	    	$teacherInfo = $this->db->get(self::$schoolUserTable)->row_array();
	    	return $teacherInfo;
		}

	    // 根据账号和学校ID，获取教师信息
	    public function get_teacher_info_by_username($userName, $schoolId){
			$this->db->where("(`username` = '{$userName}' OR `realname` = '{$userName}') ");
			$this->db->where("school_id", $schoolId);
			$this->db->where("is_delete", 0);
	    	return $this->db->get(self::$schoolUserTable)->row_array();
		}

		// 获取教师信息，根据x_teacher_id
		public function get_teacher_info_by_xid($schoolId, $xTeacherId){
			$this->db->where("school_id", $schoolId);
			$this->db->where("x_teacher_id", $xTeacherId);
			$this->db->where("is_delete", 0);
			$teacherInfo = $this->db->get(self::$schoolUserTable)->row_array();
			return $teacherInfo;
		}

	    // 根据物理卡号，获取教师信息
	    public function get_teacher_info_by_realcard($realcard, $schoolId = 0, $teacherId = 0){
			$this->db->where("is_delete", 0);
	    	$this->db->where("realcard", $realcard);
			if($schoolId) $this->db->where("school_id", $schoolId);
			// 排除本身
			if($teacherId) $this->db->where('id !=', $teacherId);

	    	$teacherInfo = $this->db->get(self::$schoolUserTable)->row_array();
	    	return $teacherInfo;
		}

	    // 获取学生信息
	    public function get_student_info($studentId){
	    	$this->db->where("id", $studentId);
	    	$studentInfo = $this->db->get(self::$schoolStudentTable)->row_array();
	    	return $studentInfo;
		}
		
	    // 根据学生物理卡号，获取学生信息
	    public function get_student_info_by_realcard($realcard, $schoolId = 0, $studentId = 0){
			$this->db->where("is_delete", 0);
	    	$this->db->where("realcard", $realcard);
			if($schoolId) $this->db->where("school_id", $schoolId);
			// 排除本身
			if($studentId) $this->db->where('id !=', $studentId);

			// 排除已毕业
			$this->db->where('is_graduated', 0);

	    	$studentInfo = $this->db->get(self::$schoolStudentTable)->row_array();
	    	return $studentInfo;
		}

		// 根据学生身份证，获取学生信息
		public function get_student_info_by_shenfenzheng($realcard, $schoolId = 0, $studentId = 0){
			$this->db->where("is_delete", 0);
			$this->db->where("shenfenzheng", $realcard);
			if($schoolId) $this->db->where("school_id", $schoolId);
			// 排除本身
			if($studentId) $this->db->where('id !=', $studentId);

			// 排除已毕业
			$this->db->where('is_graduated', 0);

			$studentInfo = $this->db->get(self::$schoolStudentTable)->row_array();
			return $studentInfo;
		}
		
	    // 根据学生实名，获取学生信息
	    public function get_student_info_by_realname($realname, $schoolId = 0, $studentId = 0, $studentNum = ''){
			$this->db->where("is_delete", 0);
	    	$this->db->where("realname", $realname);
			if($schoolId) $this->db->where("school_id", $schoolId);
			// 排除本身
			if($studentId) $this->db->where('id !=', $studentId);
			// 筛选学号
			if($studentNum) $this->db->where('username', $studentNum);

			// 排除已毕业
			$this->db->where('is_graduated', 0);
						
	    	$studentInfo = $this->db->get(self::$schoolStudentTable)->row_array();
	    	return $studentInfo;
		}

	    // 根据学生ticket,获取学生信息
	    public function get_student_info_by_ticket($ticket){
	    	$this->db->where("ticket", $ticket);
	    	$studentInfo = $this->db->get(self::$schoolStudentTable)->row_array();
	    	return $studentInfo;
		}
		
	    // 获取学生列表，获取数据量大是时间较久
	    public function get_student_list_join_bind($params = ""){
			$studentTb = self::$schoolStudentTable;
			$wxUserBindTb = self::$wxUserBindTable;
			// 连表查询
			$bindStudent = BIND_TYPE_STUDENT;
			$this->db->join($wxUserBindTb, "{$studentTb}.id = {$wxUserBindTb}.bind_user_id AND {$wxUserBindTb}.is_delete=0 AND {$wxUserBindTb}.bind_user_type= {$bindStudent} AND {$wxUserBindTb}.wx_user_id!=0", 'left');
			$this->db->group_by("{$studentTb}.id");
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// // 读取指定列
	    	// if(isset($params['field'])) $this->db->select($params['field']);
	    	// 只获取学生列表
			$where = "1 AND 1";
	    	// 学校id
	    	if(isset($params['schoolId'])) $where .= " AND {$studentTb}.`school_id`='{$params['schoolId']}'";
	    	if(isset($params['campusId'])) $where .= " AND {$studentTb}.`campus_id`='{$params['campusId']}'";
	    	// 班级id
	    	if(isset($params['classId'])) $where .= " AND {$studentTb}.`class_id`='{$params['classId']}'";
			if(isset($params['teachId'])) $where .= " AND FIND_IN_SET('{$params['teachId']}', `teaching_class_id`)";
			if(isset($params['electiveId'])) $where .= " AND FIND_IN_SET('{$params['electiveId']}', `elective_class_id`)";
	    	if(isset($params['classSet'])) $where .= " AND {$studentTb}.`class_id` IN ({$params['classSet']})";
	    	// 原来模糊搜索行政班和教学班,排除查询参数为空的情况
	    	if(isset($params['classORteach']) && !empty($params['classORteach'])) {
	    		// 班级ID 
	    		$classArray = explode(",", $params['classORteach']);
	    		// 获取教学班查询数组
	    		$orSqlArray = array();
	    		foreach($classArray as $class) $orSqlArray[] = "FIND_IN_SET('{$class}', `teaching_class_id`) OR FIND_IN_SET('{$class}', `elective_class_id`) ";
	    		$orSql = implode(" OR ", $orSqlArray);

	    		$where .= " AND ({$studentTb}.`class_id` IN ({$params['classORteach']}) OR ($orSql))";
	    	}
	    	// 关键字筛选
	    	if(isset($params['keyword'])) $where .= " AND {$studentTb}.`realname` LIKE '%{$params['keyword']}%'";
	    	// 获取班干
	    	if(isset($params['job'])) $where .= " AND {$studentTb}.`job` != ''";
	    	// 删除状态
			if(isset($params['isDelete'])) $where .= " AND {$studentTb}.`is_delete`='{$params['isDelete']}'";
			// 获取x_student_id不为空的，即同步过来的学生数据
			if(isset($params['xStudentId'])) $where .= " AND {$studentTb}.`x_student_id` <> ''";
			// 筛选账号
			if(isset($params['username'])) $where .= " AND {$studentTb}.`username`= '{$params['username']}'";
			// 过期
			$nowDate = date('Y-m-d');
			if(isset($params['expired'])) $where .= " AND ({$studentTb}.`expire_date` = '' OR {$studentTb}.`expire_date` <= '{$nowDate}')";
			// 是否过期
			if(isset($params['isExpired']) && !empty($params['isExpired'])) {
				if($params['isExpired'] == 1) {
					// 过期
					$where .= " AND ({$studentTb}.`expire_date` = '' OR {$studentTb}.`expire_date` <= '{$nowDate}')";
				} elseif($params['isExpired'] == 2) {
					// 没过期
					$where .= " AND {$studentTb}.`expire_date` != '' AND {$studentTb}.`expire_date` > '{$nowDate}'";
				}
			}
			// 是否已绑定
			if(isset($params['bind'])) {
				if($params['bind'] == 1) {
					$bindStudent = BIND_TYPE_STUDENT;
					$where .= " AND {$wxUserBindTb}.`is_delete`='0'";
					$where .= " AND {$wxUserBindTb}.`wx_user_id`!='0'";
					$where .= " AND {$wxUserBindTb}.`bind_user_type`='{$bindStudent}'";
				} elseif($params['bind'] == 2) {
					// 学生未绑定情况
					$bindTeacher = BIND_TYPE_TEACHER;
					$where .= " AND ({$wxUserBindTb}.`bind_user_type` IS NULL OR {$wxUserBindTb}.`bind_user_type`='{$bindTeacher}')";
				}
			}
			// 是否已录入人脸
			if(isset($params['hasFaceImage'])) {
				if($params['hasFaceImage'] == 1) {
					$where .= " AND {$studentTb}.`face_image` != ''";
				} else {
					$where .= " AND {$studentTb}.`face_image` = ''";
				}
			}
			// 是否已录入人脸或物理卡号
			if(isset($params['hasFaceImageOrRealcard'])) {
				if($params['hasFaceImageOrRealcard'] == 1) {
					$where .= " AND ({$studentTb}.`face_image` != '' OR {$studentTb}.`realcard` != '' )";
				}
			}
			// 默认排除已毕业
			if(!isset($params['includeGraduated'])) {
				$where .= " AND {$studentTb}.`is_graduated` = 0";
			}
			// 学生分组
			if(isset($params['group'])) {
				if($params['group'] == '-1') {
					// 未分组
					$where .= " AND {$studentTb}.`group_ids` = ''";
				} else {
					$where .= " AND FIND_IN_SET('{$params['group']}', `group_ids`)";
				}
			}
			$this->db->where($where);
			// 连表查询不能没有这个
			// 用.*查询比较慢
			// $this->db->select("{$studentTb}.*");
			$this->db->select("{$studentTb}.id,{$studentTb}.class_id,{$studentTb}.teaching_class_id,{$studentTb}.elective_class_id,{$studentTb}.gender,{$studentTb}.realname,
			{$studentTb}.face_image,{$studentTb}.expire_date,{$studentTb}.realcard,{$studentTb}.job,{$studentTb}.username,{$studentTb}.mobile,{$studentTb}.seat_no,{$studentTb}.group_ids");
			// 排序
			if(isset($params['orderBy'])) {
				$this->db->order_by("{$studentTb}." . $params['orderBy']);
			}
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) {
	    		$result = $this->db->count_all_results(self::$schoolStudentTable);
	    	} else {
	    		$result = $this->db->get(self::$schoolStudentTable)->result_array();	
	    	}
	    	return $result;
		}
	    // 获取学生列表
	    public function get_student_list($params = ""){
			$studentTb = self::$schoolStudentTable;
			$wxUserBindTb = self::$wxUserBindTable;
			// // 连表查询
			// $bindStudent = BIND_TYPE_STUDENT;
			// $this->db->join($wxUserBindTb, "{$studentTb}.id = {$wxUserBindTb}.bind_user_id AND {$wxUserBindTb}.is_delete=0 AND {$wxUserBindTb}.bind_user_type= {$bindStudent} ", 'left');
			// $this->db->group_by("{$studentTb}.id");
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 只获取学生列表
			$where = "1 AND 1";
	    	// 学校id
	    	if(isset($params['schoolId'])) $where .= " AND {$studentTb}.`school_id`='{$params['schoolId']}'";
	    	if(isset($params['campusId'])) $where .= " AND {$studentTb}.`campus_id`='{$params['campusId']}'";
	    	// 班级id
	    	if(isset($params['classId'])) $where .= " AND {$studentTb}.`class_id`='{$params['classId']}'";
			if(isset($params['teachId'])) $where .= " AND FIND_IN_SET('{$params['teachId']}', `teaching_class_id`)";
			if(isset($params['electiveId'])) $where .= " AND FIND_IN_SET('{$params['electiveId']}', `elective_class_id`)";
	    	if(isset($params['classSet'])) $where .= " AND {$studentTb}.`class_id` IN ({$params['classSet']})";
	    	// 原来模糊搜索行政班和教学班,排除查询参数为空的情况
	    	if(isset($params['classORteach']) && !empty($params['classORteach'])) {
	    		// 班级ID 
	    		$classArray = explode(",", $params['classORteach']);
	    		// 获取教学班查询数组
	    		$orSqlArray = array();
	    		foreach($classArray as $class) $orSqlArray[] = "FIND_IN_SET('{$class}', `teaching_class_id`) OR FIND_IN_SET('{$class}', `elective_class_id`)";
	    		$orSql = implode(" OR ", $orSqlArray);

	    		$where .= " AND ({$studentTb}.`class_id` IN ({$params['classORteach']}) OR ($orSql))";
	    	}
	    	// 关键字筛选
	    	if(isset($params['keyword'])) $where .= " AND {$studentTb}.`realname` LIKE '%{$params['keyword']}%'";
	    	// 获取班干
	    	if(isset($params['job'])) $where .= " AND {$studentTb}.`job` != ''";
	    	// 删除状态
			if(isset($params['isDelete'])) $where .= " AND {$studentTb}.`is_delete`='{$params['isDelete']}'";
			// 获取x_student_id不为空的，即同步过来的学生数据
			if(isset($params['xStudentId'])) $where .= " AND {$studentTb}.`x_student_id` <> ''";
			// 筛选账号
			if(isset($params['username'])) $where .= " AND {$studentTb}.`username`= '{$params['username']}'";
			// 筛选姓名
			if(isset($params['realname'])) $where .= " AND {$studentTb}.`realname`= '{$params['realname']}'";
			// 过期
			$nowDate = date('Y-m-d');
			if(isset($params['expired'])) $where .= " AND ({$studentTb}.`expire_date` = '' OR {$studentTb}.`expire_date` <= '{$nowDate}')";
			// 是否过期
			if(isset($params['isExpired']) && !empty($params['isExpired'])) {
				if($params['isExpired'] == 1) {
					// 过期
					$where .= " AND ({$studentTb}.`expire_date` = '' OR {$studentTb}.`expire_date` <= '{$nowDate}')";
				} elseif($params['isExpired'] == 2) {
					// 没过期
					$where .= " AND {$studentTb}.`expire_date` != '' AND {$studentTb}.`expire_date` > '{$nowDate}'";
				}
			}
			// 是否即将过期
			if(isset($params['expiredSoon']) && !empty($params['expiredSoon'])) {
				$dateBefore = date('Y-m-d', strtotime('+7 days'));
				if($params['expiredSoon'] == 1) {
					// 过期
					$where .= " AND ({$studentTb}.`expire_date` = '' OR {$studentTb}.`expire_date` <= '{$dateBefore}')";
				}
			}
			// 是否已录入人脸
			if(isset($params['hasFaceImage'])) {
				if($params['hasFaceImage'] == 1) {
					$where .= " AND {$studentTb}.`face_image` != ''";
				} else {
					$where .= " AND {$studentTb}.`face_image` = ''";
				}
			}
			// 是否已录入人脸或物理卡号
			if(isset($params['hasFaceImageOrRealcard'])) {
				if($params['hasFaceImageOrRealcard'] == 1) {
					$where .= " AND ({$studentTb}.`face_image` != '' OR {$studentTb}.`realcard` != '' )";
				}
			}
			// 默认排除已毕业
			if(!isset($params['includeGraduated'])) {
				$where .= " AND {$studentTb}.`is_graduated` = 0";
			}

			// 限制增值功能
			if(isset($params['limit'])) $where .= " AND {$studentTb}.`is_limit`='{$params['limit']}'";
			$this->db->where($where);
			if(isset($params['field'])) {
				$this->db->select($params['field']);
			} else {
				// 连表查询不能没有这个
				$this->db->select("{$studentTb}.*");
			}
			// 排序
			if(isset($params['orderBy'])) {
				$this->db->order_by("{$studentTb}." . $params['orderBy']);
			}
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) {
	    		$result = $this->db->count_all_results(self::$schoolStudentTable);
	    	} else {
	    		$result = $this->db->get(self::$schoolStudentTable)->result_array();	
	    	}
	    	return $result;
	    }
	    // 获取学生列表，连接门锁白名单
	    public function get_student_list_join_smart_lock_white_list($params = ""){
			$studentTb = self::$schoolStudentTable;
			$smartLockStudentWhiteListTb = self::$smartLockStudentWhiteListTable;
			// 连表查询
			$this->db->join($smartLockStudentWhiteListTb, "{$studentTb}.id = {$smartLockStudentWhiteListTb}.student_id AND {$smartLockStudentWhiteListTb}.is_delete=0", 'left');
			$this->db->group_by("{$studentTb}.id");
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 只获取学生列表
			$where = "1 AND 1";
	    	// 学校id
	    	if(isset($params['schoolId'])) $where .= " AND {$studentTb}.`school_id`='{$params['schoolId']}'";
	    	if(isset($params['campusId'])) $where .= " AND {$studentTb}.`campus_id`='{$params['campusId']}'";
	    	// 班级id
	    	if(isset($params['classId'])) $where .= " AND {$studentTb}.`class_id`='{$params['classId']}'";
			if(isset($params['teachId'])) $where .= " AND FIND_IN_SET('{$params['teachId']}', `teaching_class_id`)";
			if(isset($params['electiveId'])) $where .= " AND FIND_IN_SET('{$params['electiveId']}', `elective_class_id`)";
	    	if(isset($params['classSet'])) $where .= " AND {$studentTb}.`class_id` IN ({$params['classSet']})";
	    	// 原来模糊搜索行政班和教学班,排除查询参数为空的情况
	    	if(isset($params['classORteach']) && !empty($params['classORteach'])) {
	    		// 班级ID 
	    		$classArray = explode(",", $params['classORteach']);
	    		// 获取教学班查询数组
	    		$orSqlArray = array();
	    		foreach($classArray as $class) $orSqlArray[] = "FIND_IN_SET('{$class}', `teaching_class_id`) OR FIND_IN_SET('{$class}', `elective_class_id`) ";
	    		$orSql = implode(" OR ", $orSqlArray);

	    		$where .= " AND ({$studentTb}.`class_id` IN ({$params['classORteach']}) OR ($orSql))";
	    	}
	    	// 关键字筛选
	    	if(isset($params['keyword'])) $where .= " AND {$studentTb}.`realname` LIKE '%{$params['keyword']}%'";
	    	// 删除状态
			if(isset($params['isDelete'])) $where .= " AND {$studentTb}.`is_delete`='{$params['isDelete']}'";
			// 筛选账号
			if(isset($params['username'])) $where .= " AND {$studentTb}.`username`= '{$params['username']}'";

			// 是否白名单
			if(isset($params['isWhiteList'])) {
				if($params['isWhiteList'] == 1) {
					$where .= " AND {$smartLockStudentWhiteListTb}.`id` IS NOT NULL";
				} else {
					$where .= " AND {$smartLockStudentWhiteListTb}.`id` IS NULL";
				}
			}

			// 默认排除已毕业
			if(!isset($params['includeGraduated'])) {
				$where .= " AND {$studentTb}.`is_graduated` = 0";
			}
			
			$this->db->where($where);
			// 连表查询不能没有这个
			// 用.*查询比较慢
			$this->db->select("{$studentTb}.id,{$studentTb}.class_id,{$studentTb}.gender,{$studentTb}.realname,{$studentTb}.username,
			{$smartLockStudentWhiteListTb}.id as white_list_id ");
			// 排序
			if(isset($params['orderBy'])) {
				$this->db->order_by("{$studentTb}." . $params['orderBy']);
			}
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) {
	    		$result = $this->db->count_all_results(self::$schoolStudentTable);
	    	} else {
	    		$result = $this->db->get(self::$schoolStudentTable)->result_array();	
	    	}
	    	return $result;
		}
	    // 获取课程信息
	    public function get_lesson_info($lessonId) {
	    	$this->db->where("id", $lessonId);
	    	return $this->db->get(self::$schoolLessonTable)->row_array();
		}
		// 通过课程名获取课程信息
		public function get_lesson_info_by_name($lessonName, $schoolId) {
			$this->db->where('school_id', $schoolId);
			$this->db->where("lesson_name", $lessonName);
			$this->db->where('is_delete', 0);
	    	return $this->db->get(self::$schoolLessonTable)->row_array();
		}

	    // 获取课程列表
	    public function get_lesson_list($params = ""){
	    	$where = "1 AND 1";
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 读取指定列
	    	if(isset($params['field'])) $this->db->select($params['field']);
	    	// 学校id
	    	if(isset($params['schoolId'])) $where .= " AND `school_id`='{$params['schoolId']}'";

			// 筛选
			if(isset($params['keyword'])) $where .= " AND `lesson_name` LIKE '%{$params['keyword']}%'";

	    	// 删除状态
	    	if(isset($params['isDelete'])) $where .= " AND `is_delete`='{$params['isDelete']}'";
			$this->db->where($where);
			// 排序
			if(isset($params['orderBy'])) {
				$this->db->order_by($params['orderBy']['order'], $params['orderBy']['sort']);
			} else {
				// 默认按更新时间
				$this->db->order_by('updatetime', 'DESC');
			}
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) {
	    		$result = $this->db->count_all_results(self::$schoolLessonTable);
	    	} else {
	    		$result = $this->db->get(self::$schoolLessonTable)->result_array();	
	    	}
	    	return $result;
	    }

		//检查科目名称是否存在
	    public function check_subject_name_exists($schoolId, $subjectName, $subjectId = 0){
	    	$this->db->where("school_id", $schoolId);
			$this->db->where("lesson_name", $subjectName);
			$this->db->where('is_delete', 0);
	    	if($subjectId) {
				$this->db->where("id !=", $subjectId);
			}
			return $this->db->get(self::$schoolLessonTable)->row_array();
		}

	    // 获取地址省市区列表
	    public function get_area_list($params = ''){
			if(isset($params['field'])) {
				$this->db->select($params['field']);
			}
	    	$where = 1;
			if(isset($params['parentId'])) $where .= " AND `parent_id`='{$params['parentId']}'";
			if($where !== 1) {
				$this->db->where($where);
			}
			return $this->db->get(self::$areaTable)->result_array();
	    }
	    // 根据省市区编码，获取省市区信息
	    public function get_area_info($areaCode){
	    	$this->db->where("area_code", $areaCode);
	    	$areaInfo = $this->db->get(self::$areaTable)->row_array();
	    	return $areaInfo;
		}
		// 根据id获取地区信息
		public function get_area_info_by_id($id){
			$this->db->where('id', $id);
			return $this->db->get(self::$areaTable)->row_array();
		}
	    // 获取校区列表
	    public function get_campus_list($params = ""){
	    	// 查询
	    	$where = "1 AND 1";
	    	if(isset($params['schoolId'])) $where .= " AND `school_id`='{$params['schoolId']}'";
	    	// 删除状态
	    	if(isset($params['isDelete'])) $where .= " AND `is_delete`='{$params['isDelete']}'";
	    	$this->db->where($where);
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$campusTable);
	    	return $this->db->order_by('id ASC')->get(self::$campusTable)->result_array();
		}
	    // 获取某班班长
	    public function get_monitor($classId){
			$this->db->where('class_id', $classId);
			$this->db->where('is_delete', 0);
			$this->db->where('job', '班长');
			$this->db->select('id, realname as name, headimgurl, realCard as cardnum, face_image as faceImage');
			return $this->db->get(self::$schoolStudentTable)->row_array();
		}
		
	    // 获取班级信息
	    public function get_campus_info($campusId){
	    	$where = "`id`='{$campusId}'";
	    	$campusInfo = $this->db->where($where)->get(self::$campusTable)->row_array();
	    	return $campusInfo;
		}
		
	    // 获取外链列表
	    public function get_custom_menu_list($params = ""){
			$this->db->where('is_delete', 0);
			if(isset($params['schoolId'])) {
				$this->db->where('school_id', $params['schoolId']);
			}
			if(isset($params['position'])) {
				$this->db->where("FIND_IN_SET('{$params['position']}', `position`)");
			}
			if(isset($params['field'])) {
				$this->db->select($params['field']);
			}
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$customMenuTable);
	    	return $this->db->order_by("'createtime' DESC")->get(self::$customMenuTable)->result_array();
		}

	    // 获取外链信息
	    public function get_custom_menu_info($id){
	    	$where = "`id`='{$id}'";
	    	$menuInfo = $this->db->where($where)->get(self::$customMenuTable)->row_array();
	    	return $menuInfo;
		}

	    // 获取收费项列表
	    public function get_charge_list($params = ""){
	    	// 查询
	    	$where = "1 AND 1";
	    	if(isset($params['schoolId'])) $where .= " AND `school_id`='{$params['schoolId']}'";
	    	// 删除状态
	    	if(isset($params['isDelete'])) $where .= " AND `is_delete`='{$params['isDelete']}'";
	    	$this->db->where($where);
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$chargeTable);
	    	return $this->db->order_by('id ASC')->get(self::$chargeTable)->result_array();
		}
		
	    // 获取收费项信息
	    public function get_charge_info($id){
	    	$where = "`id`='{$id}'";
	    	$chargeInfo = $this->db->where($where)->get(self::$chargeTable)->row_array();
	    	return $chargeInfo;
		}

	    // 获取闸机列表
	    public function get_gate_list($params = ""){
	    	// 查询
	    	$where = "1 AND 1";
			if(isset($params['schoolId'])) $where .= " AND `school_id`='{$params['schoolId']}'";
			if(isset($params['campusId'])) $where .= " AND `campus_id`='{$params['campusId']}'";
	    	// 删除状态
	    	if(isset($params['isDelete'])) $where .= " AND `is_delete`='{$params['isDelete']}'";
			// 分组
			if(isset($params['studentGroupId'])) $where .= " AND `student_group_id`='{$params['studentGroupId']}'";
	    	$this->db->where($where);
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$gateTable);
	    	return $this->db->order_by('id ASC')->get(self::$gateTable)->result_array();
		}
		
	    // 获取闸机信息
	    public function get_gate_info($id){
	    	$where = "`id`='{$id}'";
	    	$gateInfo = $this->db->where($where)->get(self::$gateTable)->row_array();
	    	return $gateInfo;
		}

	    // 获取闸机信息，通过序列号
	    public function get_gate_info_device_sn($schoolId, $deviceSn){
	    	$this->db->where('school_id', $schoolId);
			$this->db->where('device_sn', $deviceSn);
			$this->db->where('is_delete', 0);
	    	$gateInfo = $this->db->get(self::$gateTable)->row_array();
	    	return $gateInfo;
		}

	    // 获取闸机任务列表
	    public function get_gate_task_list($params = ""){
	    	// 查询
			$where = "1 AND 1";
			if(isset($params['schoolId'])) $where .= " AND `school_id`='{$params['schoolId']}'";
			if(isset($params['campusId'])) $where .= " AND `campus_id`='{$params['campusId']}'";
	    	// 闸机id
			if(isset($params['gateId'])) $where .= " AND `gate_id`='{$params['gateId']}'";
			// 学生名称
			if(isset($params['realname'])) $where .= " AND `user_name` LIKE '%{$params['realname']}%'";
	    	// 任务类型
			if(isset($params['taskType'])) $where .= " AND `task_type`='{$params['taskType']}'";
			// 用户类型
			if(isset($params['userType'])) $where .= " AND user_type`='{$params['userType']}'";			
			// 任务状态
			if(isset($params['taskState'])) $where .= " AND `task_state`='{$params['taskState']}'";
	    	// 删除状态
	    	if(isset($params['isDelete'])) $where .= " AND `is_delete`='{$params['isDelete']}'";
	    	$this->db->where($where);
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$gateTaskTable);
			// 排序
			if(isset($params['orderBy'])) {
				$this->db->order_by($params['orderBy']['order'], $params['orderBy']['sort']);
			} else {
				// 默认按创建时间
				$this->db->order_by('createtime', 'DESC');
			}
	    	return $this->db->get(self::$gateTaskTable)->result_array();
		}
		
	    // 获取闸机任务信息
	    public function get_gate_task_info($id){
	    	$where = "`id`='{$id}'";
	    	$gateTaskInfo = $this->db->where($where)->get(self::$gateTaskTable)->row_array();
	    	return $gateTaskInfo;
		}


		// 封装闸机任务数组
		public function format_gate_task($schoolId, $campusId, $gateId, $deviceSn, $userId, $realname, $faceimage, $userType, $taskType, $taskState, $realcard){
			$now = date('Y-m-d H:i:s');
			$arr = array(
				'school_id' => $schoolId,
				'campus_id' => $campusId,
				'gate_id' => $gateId,
				'device_sn' => $deviceSn,
				'user_id' => $userId,
				'user_name' => $realname,
				'user_face_image' => $faceimage,
				'user_type' => $userType,
				'task_type' => $taskType,
				'task_state' => $taskState,
				'createtime' => $now,
				'updatetime' => $now,
				'user_realcard' => $realcard
			);
			return $arr;
		}

		// 插入闸机任务
		public function insert_gate_task_batch($insertTaskBatch){
			$this->db->insert_batch(SchoolModel::$gateTaskTable, $insertTaskBatch);
		}

		//检查设备编码是否存在
		public function check_gate_sn_exists($schoolId, $campusId, $deviceSn, $id = 0){
			$this->db->where("device_sn", $deviceSn);
			$this->db->where("school_id", $schoolId);
			$this->db->where("campus_id", $campusId);
			$this->db->where('is_delete', 0);
			if($id){
				$this->db->where("id !=", $id);
			}
			return $this->db->get(self::$gateTable)->row_array();
		}

	    // 获取智能门锁列表
	    public function get_smart_lock_list($params = ""){
	    	// 查询
	    	$where = "1 AND 1";
			if(isset($params['schoolId'])) $where .= " AND `school_id`='{$params['schoolId']}'";
			if(isset($params['campusId'])) $where .= " AND `campus_id`='{$params['campusId']}'";
			if(isset($params['classId'])) $where .= " AND `class_id`='{$params['classId']}'";
	    	// 删除状态
	    	if(isset($params['isDelete'])) $where .= " AND `is_delete`='{$params['isDelete']}'";
			// 读取指定列
			if(isset($params['field'])) $this->db->select($params['field']);
	    	$this->db->where($where);
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$smartLockTable);
	    	return $this->db->order_by('id ASC')->get(self::$smartLockTable)->result_array();
		}
		
	    // 获取智能门锁信息
	    public function get_smart_lock_info($id){
	    	$where = "`id`='{$id}'";
	    	$smartLockInfo = $this->db->where($where)->get(self::$smartLockTable)->row_array();
	    	return $smartLockInfo;
		}

		//获取智能门锁信息，通过设备id
		public function get_smart_lock_info_by_device_id($schoolId, $campusId, $deviceId){
			$this->db->where("device_id", $deviceId);
			$this->db->where("school_id", $schoolId);
			$this->db->where("campus_id", $campusId);
			$this->db->where('is_delete', 0);
			return $this->db->get(self::$smartLockTable)->row_array();
		}

		//检查设备id是否存在
		public function check_smart_lock_device_id_exists($schoolId, $campusId, $deviceId, $id = 0){
			$this->db->where("device_id", $deviceId);
			$this->db->where("school_id", $schoolId);
			$this->db->where("campus_id", $campusId);
			$this->db->where('is_delete', 0);
			if($id){
				$this->db->where("id !=", $id);
			}
			return $this->db->get(self::$smartLockTable)->row_array();
		}

		//检查设备关联班级id是否存在
		public function check_smart_lock_class_id_exists($schoolId, $campusId, $classId, $id = 0){
			$this->db->where("class_id", $classId);
			$this->db->where("school_id", $schoolId);
			$this->db->where("campus_id", $campusId);
			$this->db->where('is_delete', 0);
			if($id){
				$this->db->where("id !=", $id);
			}
			return $this->db->get(self::$smartLockTable)->row_array();
		}

		// 获取智能门锁白名单信息，通过学生id
		public function get_smart_lock_student_white_list_info_by_student_id($studentId){
			$where = "`student_id`='{$studentId}' AND `is_delete`=0";
			$info = $this->db->where($where)->get(self::$smartLockStudentWhiteListTable)->row_array();
			return $info;
		}

	    // 获取智能门锁开锁记录列表
	    public function get_smart_lock_unlock_record_list($params = ""){
	    	// 查询
	    	$where = "1 AND 1";
			if(isset($params['schoolId'])) $where .= " AND `school_id`='{$params['schoolId']}'";
			if(isset($params['campusId'])) $where .= " AND `campus_id`='{$params['campusId']}'";
			if(isset($params['classId'])) $where .= " AND `class_id`='{$params['classId']}'";
			if(isset($params['studentId'])) $where .= " AND `student_id`='{$params['studentId']}'";
	    	if(isset($params['createtimeMin'])) $where .= " AND `createtime` LIKE '{$params['createtimeMin']}%'";
			if(isset($params['smartLockId'])) $where .= " AND `smart_lock_id`='{$params['smartLockId']}'";
			if(isset($params['userType'])) $where .= " AND `user_type`='{$params['userType']}'";
			if(isset($params['userId'])) $where .= " AND `user_id`='{$params['userId']}'";
	    	// 关键字筛选
	    	if(isset($params['keyword'])) $where .= " AND `realname` LIKE '%{$params['keyword']}%'";
	    	$this->db->where($where);
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$smartLockUnlockRecordTable);
	    	return $this->db->order_by('id DESC')->get(self::$smartLockUnlockRecordTable)->result_array();
		}

		// 获取学生分组列表
		public function get_student_group_list($params = ""){
			// 查询
			$where = "1 AND 1";
			if(isset($params['schoolId'])) $where .= " AND `school_id`='{$params['schoolId']}'";
			if(isset($params['campusId'])) $where .= " AND `campus_id`='{$params['campusId']}'";
			if(isset($params['isDelete'])) $where .= " AND `is_delete`='{$params['isDelete']}'";
			$this->db->where($where);
			// 分页
			if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
			// 是否只获取条数
			if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$schoolStudentGroupTable);
			return $this->db->order_by('id DESC')->get(self::$schoolStudentGroupTable)->result_array();
		}

		//检查是否存在
		public function check_student_group_name_exists($schoolId, $name, $id = 0){
			$this->db->where("group_name", $name);
			$this->db->where("school_id", $schoolId);
			$this->db->where('is_delete', 0);
			if($id){
				$this->db->where("id !=", $id);
			}
			return $this->db->get(self::$schoolStudentGroupTable)->row_array();
		}

		// 获取学生分组信息
		public function get_student_group_info($id){
			$where = "`id`='{$id}'";
			$info = $this->db->where($where)->get(self::$schoolStudentGroupTable)->row_array();
			return $info;
		}
	}